﻿using System;
using log4net;
using log4net.Config;

namespace Microhard.Core
{
    
    public static class Log
    {
        static Log()
        {
            XmlConfigurator.Configure();
        }

        public static void Info(string cat, Exception ex)
        {
            ILog logger = LogManager.GetLogger(cat);
            if (logger != null && logger.IsInfoEnabled)
            {
                logger.Info(ex);
            }
        }

        public static void Info(string cat, object message)
        {
            ILog logger = LogManager.GetLogger(cat);
            if (logger != null && logger.IsInfoEnabled)
            {
                logger.Info(message);
            }
        }

        public static void Info(string cat, string format, params object[] args)
        {
            ILog logger = LogManager.GetLogger(cat);
            if (logger != null && logger.IsInfoEnabled)
            {
                logger.InfoFormat(format, args);
            }
        }

        public static void Debug(string cat, Exception ex)
        {
            ILog logger = LogManager.GetLogger(cat);
            if (logger != null && logger.IsInfoEnabled)
            {
                logger.Info(ex);
            }
        }

        public static void Debug(string cat, object message)
        {
            ILog logger = LogManager.GetLogger(cat);
            if (logger != null && logger.IsDebugEnabled)
            {
                logger.Debug(message);
            }
        }

        public static void Debug(string cat, string format, params object[] args)
        {
            ILog logger = LogManager.GetLogger(cat);
            if (logger != null && logger.IsDebugEnabled)
            {
                logger.DebugFormat(format, args);
            }
        }

        public static void Warn(string cat, Exception ex)
        {
            ILog logger = LogManager.GetLogger(cat);
            if (logger != null && logger.IsInfoEnabled)
            {
                logger.Info(ex);
            }
        }

        public static void Warn(string cat, object message)
        {
            ILog logger = LogManager.GetLogger(cat);
            if (logger != null && logger.IsWarnEnabled)
            {
                logger.Warn(message);
            }
        }

        public static void Warn(string cat, string format, params object[] args)
        {
            ILog logger = LogManager.GetLogger(cat);
            if (logger != null && logger.IsWarnEnabled)
            {
                logger.WarnFormat(format, args);
            }
        }

        public static void Error(string cat, Exception ex)
        {
            ILog logger = LogManager.GetLogger(cat);
            if (logger != null && logger.IsInfoEnabled)
            {
                logger.Info(ex);
            }
        }

        public static void Error(string cat, object message)
        {
            ILog logger = LogManager.GetLogger(cat);
            if (logger != null && logger.IsErrorEnabled)
            {
                logger.Error(message);
            }
        }

        public static void Error(string cat, string format, params object[] args)
        {
            ILog logger = LogManager.GetLogger(cat);
            if (logger != null && logger.IsErrorEnabled)
            {
                logger.ErrorFormat(format, args);
            }
        }

        public static void Fatal(string cat, Exception ex)
        {
            ILog logger = LogManager.GetLogger(cat);
            if (logger != null && logger.IsInfoEnabled)
            {
                logger.Info(ex);
            }
        }

        public static void Fatal(string cat, object message)
        {
            ILog logger = LogManager.GetLogger(cat);
            if (logger != null && logger.IsFatalEnabled)
            {
                logger.Fatal(message);
            }
        }

        public static void Fatal(string cat, string format, params object[] args)
        {
            ILog logger = LogManager.GetLogger(cat);
            if (logger != null && logger.IsFatalEnabled)
            {
                logger.FatalFormat(format, args);
            }
        }
    }
}